package com.kuang.demo.controller;

import com.kuang.demo.bean.BaseRespVo;
import com.kuang.demo.bean.acgBeanVo.BaseData;
import com.kuang.demo.bean.lhf.GrouponRules;
import com.kuang.demo.service.GrouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/groupon")
public class GrouponController {

    @Autowired
    GrouponService grouponService;

    @RequestMapping("list")
    public BaseRespVo list(Integer page, Integer limit, String sort, String order, String goodsId){
        //获取所需数据int id = Integer.parseInt(goodsId);
        BaseData data = grouponService.queryGrouponList(page, limit, sort, order,goodsId);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("listRecord")
    public BaseRespVo listRecord(Integer page, Integer limit, String sort, String order){
        //获取所需数据
        BaseData data = grouponService.queryRecordList(page, limit, sort, order);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody GrouponRules grouponRules){
        grouponService.updateGrouponRules(grouponRules);
        return BaseRespVo.ok();
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody GrouponRules grouponRules){
        grouponService.deleteGrouponRules(grouponRules);
        return BaseRespVo.ok();
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody GrouponRules grouponRules){
        GrouponRules createGrouponRules = grouponService.createGrouponRules(grouponRules);
        return BaseRespVo.ok(createGrouponRules);
    }
}
